package com.hulk.rpc.loadbalance.impl;

import com.hulk.rpc.loadbalance.LoadBalance;
import com.hulk.rpc.loadbalance.Weightable;
import io.netty.util.internal.ThreadLocalRandom;

/**
 * @author xuxukang
 * @date 2019-03-27 17:53
 */
public class RandomLoadBalance<T extends Weightable> extends LoadBalance<T> {

  @Override
  public T select() {
    ThreadLocalRandom random = ThreadLocalRandom.current();
    return resources.get(random.nextInt(resources.size()));
  }

  @Override
  public void clean() {
    // ignore
  }

}
